<?php
class Model_ProductFilterValue extends Zend_Db_Table_Abstract{
	protected $_name = 'product_filtervalue';
	protected $_referenceMap = array(
		"Product" => array(
			"columns" => "product_id",
			"refTableClass" => "Model_Product",
			"refColumns" => "id"
		),
		"FilterValue" => array(
			"columns" => "filtervalue_id",
			"refTableClass" => "Model_FilterValue",
			"refColumns" => "id"
		)
	);
	public function createProductFilterValue($product_id, $filtervalue_id){
		$row = $this->createRow();
		$row->product_id = $product_id;
		$row->filtervalue_id = $filtervalue_id;
		try{
			$row->save();
			return true;
		}catch(Exception $ex){
			echo "Caught Exception: " + $ex->getMessage();
			return false;
		}
	}
	public function updateProductFilterValue($product_id, $arrFilterValues){
		$this->deleteProductFilterValueByProductID($product_id);
		foreach ($arrFilterValues as $filterValue){
			$this->createProductFilterValue($product_id, $filterValue);
		}
	}
	public function deleteProductFilterValueByProductID($product_id){
		try{
			return $this->delete('product_id = '.$product_id);
		}catch (Exception $ex){
			echo "Caught Exception: " + $ex->getMessage();
			return false;
		}
	}
	
}